package sg.edu.nus.comp.icreate.ivletalk.events;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.util.Log;

import sg.edu.nus.comp.icreate.ivletalk.utils.xml.AbstractXmlParser;

public class EventCommitteeXmlParser extends AbstractXmlParser {

	private static final String TAG_EVENT_TITLE = "Title";

	public EventCommitteeXmlParser(InputStream input) throws XmlPullParserException {
		super(input);
	}

	public EventCommitteeXmlParser() {
		super();
	}

	public Object getResult() {
		int eventType;
		List<String> resultList = new ArrayList<String>();

		try {
			goToTag(TAG_RESULT, XmlPullParser.START_TAG);
			do {
				eventType = parser.getEventType();
				if (eventType == XmlPullParser.START_TAG && TAG_EVENT_TITLE.equals(parser.getName())) {
					parser.next();
					resultList.add(parser.getText());
				}
				parser.next();
			} while (parser.getEventType() != XmlPullParser.END_TAG || !TAG_RESULT.equals(parser.getName()));

		} catch (Exception e) {
			Log.e("error", "Error in handleActionRefresh", e);
		}

		return resultList;
	}

}
